package cn.ee.dfs;

import cn.ee.dfs.common.entity.DfsResponse;
import org.springframework.data.redis.core.ReactiveRedisOperations;
import org.springframework.data.redis.core.ReactiveRedisTemplate;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;

/**
 * Description:
 * Created by TWJ on 2019/8/21 0021 0025 下午 5:25 .
 */
public class Test {
    public static void main(String[] args) {
//        test1();
//        intToHex(12);
//        dateTest() ;
        testStr();
    }

    private static void testStr() {
        String s ="1";
        String k ="1";
        String ss ="11";
        String sss ="1"+"1";
        System.out.println(s=="1");
        System.out.println(" s hashcode:"+s.hashCode());
        System.out.println(s==k);
        System.out.println(" k hashcode:"+s.hashCode());
        System.out.println(s==sss);
        System.out.println(" sss hashcode:"+sss.hashCode());

    }

    private static void dateTest(){
//        两者最大的区别是，Java8的DateTimeFormatter是线程安全的，而SimpleDateFormat并不是线程安全。
        //解析日期
//        String dateStr= "2016年10月25日";
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
//        LocalDate date= LocalDate.parse(dateStr, formatter);

        //日期转换为字符串
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy年MM月dd日 hh:mm a");
        String nowStr = now .format(format);
        System.out.println(nowStr);
        DateTimeFormatter format2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println(LocalDateTime.now().format(format2));

    }

    private static void test1() {

//        ReactiveRedisOperations<Object, Object> redisTemplate = new ReactiveRedisTemplate<Object, Object>();
//        redisTemplate.opsForHash().put("hashValue","map1","map1-1");


        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_YEAR, 1);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
//      replaced by <code>Calendar.set(year + 1900, month, date)</code>
//     * or <code>GregorianCalendar(year + 1900, month, date)</code>.


        System.out.println(":" + cal.getTimeInMillis());
        System.out.println(":" + System.currentTimeMillis());
        System.out.println(":" + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 / 60 / 60);
    }


    public static void intToHex(int number) {
        String s = Integer.toHexString(number);
//String ss = "726C43AB";
        String ss = "726C43A";
        System.out.println(ss.length());
        System.out.println(s);
    }
}
